package ${package.Dto};

<#list table.dtoImportPackages as pkg>
import ${pkg};
</#list>

<#if entityLombokModel>
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
</#if>

/**
 * <#if table.comment??>${table.comment!} </#if>dto
 *
 * @author ${author}
 * @since ${date}
 */
<#if entityLombokModel>
@Data
    <#if superDtoClass??>
@EqualsAndHashCode(callSuper = true)
    <#else>
@EqualsAndHashCode(callSuper = false)
    </#if>
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
</#if>
<#if superDtoClass??>
public class ${dto} extends ${superDtoClass} {
<#else>
public class ${dto} implements Serializable {
</#if>

    private static final long serialVersionUID = 1L;

<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>
    <#if field.comment!?length gt 0>
    /**
     * ${field.comment}
     */
    </#if>
    private ${field.propertyType} ${field.propertyName};

</#list>
<#------------  END 字段循环遍历  ---------->
<#------------ BEGIN get/set方法 ------------>
<#if !entityLombokModel>
    <#list table.fields as field>
        <#if field.propertyType == "boolean">
            <#assign getprefix="is"/>
        <#else>
            <#assign getprefix="get"/>
        </#if>
    public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
    }

        <#if entityBuilderModel>
    public ${dto} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        <#else>
    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        </#if>
        this.${field.propertyName} = ${field.propertyName};
        <#if entityBuilderModel>
        return this;
        </#if>
    }

    </#list>
</#if>
<#------------ END get/set方法 ------------>
<#------------ BEIGN toString方法 ------------>
<#if !entityLombokModel>
    @Override
    public String toString() {
    return "${dto}{" +
    <#list table.fields as field>
        <#if field_index==0>
            "${field.propertyName}=" + ${field.propertyName} +
        <#else>
            ", ${field.propertyName}=" + ${field.propertyName} +
        </#if>
    </#list>
    "}";
    }

</#if>
<#------------ END   toString方法 ------------>
<#------------ START entity构造 ------------>
<#if dtoFromEntityConstructor>
    public ${dto}(${entity} e) {
        super();
        if (e == null) return;
        <#list table.fields as field>
            <#if field.propertyType == "boolean">
                <#assign getprefix="is"/>
            <#else>
                <#assign getprefix="get"/>
            </#if>
        this.${field.propertyName} = e.${getprefix}${field.capitalName}();
        </#list>
    }

</#if>
<#------------ END   entity构造 ------------>
}